﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using BusinessObjects.BO_GetObjects;

public partial class Pages_Index : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        Session["reference"] = Request.Url.AbsoluteUri;

        LoadTopModule();
        LoadHome1Module();
        LoadHome2Module();
        LoadHome3Module();

    }

    protected void LoadTopModule()
    {
        DataTable objDT = null;
        if (Request["cid"] != null)
        {
            objDT = BO_Module.SelectLocation(1, Convert.ToInt32(Request["cid"]));
        }
        else
            objDT = BO_Module.SelectLocation(1);
        for (int i = 0; i < objDT.Rows.Count; i++)
        {
            if (objDT.Rows[i]["type_id"].ToString() == "11")
            {
                UserControl controls = (UserControl)Page.LoadControl("../controls/TopNews.ascx");
                Controls_TopNews control = (Controls_TopNews)controls;
                control.Module_id = objDT.Rows[i]["MODULE_ID"].ToString();
                plHdTop.Controls.Add(controls);
            }
            else if (objDT.Rows[i]["type_id"].ToString() == "10")
            {
                UserControl controls = (UserControl)Page.LoadControl("../controls/ucSlider.ascx");
                Controls_ucSlider control = (Controls_ucSlider)controls;
                control.Module_id = objDT.Rows[i]["MODULE_ID"].ToString();
                plHdTop.Controls.Add(controls);
            }
            else if (objDT.Rows[i]["type_id"].ToString() == "2")
            {
                UserControl controls = (UserControl)Page.LoadControl("../controls/ucLongAds.ascx");
                Controls_ucLongAds control = (Controls_ucLongAds)controls;
                control.Module_id = objDT.Rows[i]["MODULE_ID"].ToString();
                plHdTop.Controls.Add(controls);
            }
            else if (objDT.Rows[i]["type_id"].ToString() == "17")
            {
                UserControl controls = (UserControl)Page.LoadControl("../controls/ucBid.ascx");
                Controls_ucBid control = (Controls_ucBid)controls;
                control.Module_id = objDT.Rows[i]["MODULE_ID"].ToString();
                plHdTop.Controls.Add(controls);
            }
            else if (objDT.Rows[i]["type_id"].ToString() == "18")
            {
                UserControl controls = (UserControl)Page.LoadControl("../controls/ucInvest.ascx");
                Controls_ucInvest control = (Controls_ucInvest)controls;
                control.Module_id = objDT.Rows[i]["MODULE_ID"].ToString();
                plHdTop.Controls.Add(controls);
            }
            else if (objDT.Rows[i]["type_id"].ToString() == "21")
            {
                UserControl controls = (UserControl)Page.LoadControl("../controls/ucContactus.ascx");
                plHdTop.Controls.Add(controls);
            }
        }
    }

    protected void LoadHome1Module()
    {
        DataTable objDT = null;
        if (Request["cid"] != null)
        {
            objDT = BO_Module.SelectLocation(2, Convert.ToInt32(Request["cid"]));
        }
        else
            objDT = BO_Module.SelectLocation(2);
        for (int i = 0; i < objDT.Rows.Count; i++)
        {
            if (objDT.Rows[i]["type_id"].ToString() == "3")
            {
                UserControl controls = (UserControl)Page.LoadControl("../controls/ucGreenTab.ascx");
                Controls_ucGreenTab control = (Controls_ucGreenTab)controls;
                control.Module_id = objDT.Rows[i]["MODULE_ID"].ToString();
                plhdHome1.Controls.Add(controls);
            }
            else if (objDT.Rows[i]["type_id"].ToString() == "12")
            {
                UserControl controls = (UserControl)Page.LoadControl("../controls/ucPinkTab.ascx");
                Controls_ucPinkTab control = (Controls_ucPinkTab)controls;
                control.Module_id = objDT.Rows[i]["MODULE_ID"].ToString();
                plhdHome1.Controls.Add(controls);
            }
            else if (objDT.Rows[i]["type_id"].ToString() == "7")
            {
                UserControl controls = (UserControl)Page.LoadControl("../controls/ucWeather.ascx");
                plhdHome1.Controls.Add(controls);
            }
            else if (objDT.Rows[i]["type_id"].ToString() == "8")
            {
                UserControl controls = (UserControl)Page.LoadControl("../controls/ucVote.ascx");
                plhdHome1.Controls.Add(controls);
            }
            else if (objDT.Rows[i]["type_id"].ToString() == "13")
            {
                UserControl controls = (UserControl)Page.LoadControl("../controls/ucListNews.ascx");
                Controls_ucListNews control = (Controls_ucListNews)controls;
                control.Category_id = objDT.Rows[i]["MODULE_CONTENT"].ToString();
                control.Page_size = objDT.Rows[i]["PAGE_SIZE"].ToString();
                plhdHome1.Controls.Add(controls);
            }
            else if (objDT.Rows[i]["type_id"].ToString() == "15")
            {
                UserControl controls = (UserControl)Page.LoadControl("../controls/ucNewsDetail.ascx");
                plhdHome1.Controls.Add(controls);
            }
            else if (objDT.Rows[i]["type_id"].ToString() == "19")
            {
                UserControl controls = (UserControl)Page.LoadControl("../controls/ucLogin.ascx");
                plhdHome1.Controls.Add(controls);
            }
            else if (objDT.Rows[i]["type_id"].ToString() == "20")
            {
                UserControl controls = (UserControl)Page.LoadControl("../controls/ucRegister.ascx");
                plhdHome1.Controls.Add(controls);
            }
            else if (objDT.Rows[i]["type_id"].ToString() == "22")
            {
                UserControl controls = (UserControl)Page.LoadControl("../controls/ucHomeNews.ascx");
                Controls_ucHomeNews control = (Controls_ucHomeNews)controls;
                control.News_id = "32";
                plhdHome1.Controls.Add(controls);
            }
            else if (objDT.Rows[i]["type_id"].ToString() == "23")
            {
                UserControl controls = (UserControl)Page.LoadControl("../controls/ucListProducts.ascx");
                Controls_ucListProducts control = (Controls_ucListProducts)controls;
                control.Category_id = objDT.Rows[i]["MODULE_CONTENT"].ToString();
                control.Page_size = objDT.Rows[i]["PAGE_SIZE"].ToString();
                plhdHome1.Controls.Add(controls);
            }
        }
    }

    protected void LoadHome2Module()
    {
        DataTable objDT = null;
        if (Request["cid"] != null)
        {
            objDT = BO_Module.SelectLocation(3, Convert.ToInt32(Request["cid"]));
        }
        else
            objDT = BO_Module.SelectLocation(3);
        for (int i = 0; i < objDT.Rows.Count; i++)
        {
            if (objDT.Rows[i]["type_id"].ToString() == "4")
            {
                UserControl controls = (UserControl)Page.LoadControl("../controls/ucVideo.ascx");
                plhdHome2.Controls.Add(controls);
            }
            else if (objDT.Rows[i]["type_id"].ToString() == "5")
            {
                UserControl controls = (UserControl)Page.LoadControl("../controls/ucBigAds.ascx");
                Controls_ucBigAds control = (Controls_ucBigAds)controls;
                control.Module_id = objDT.Rows[i]["MODULE_ID"].ToString();
                plhdHome2.Controls.Add(controls);
            }
            else if (objDT.Rows[i]["type_id"].ToString() == "7")
            {
                UserControl controls = (UserControl)Page.LoadControl("../controls/ucWeather.ascx");
                plhdHome2.Controls.Add(controls);
            }
            else if (objDT.Rows[i]["type_id"].ToString() == "8")
            {
                UserControl controls = (UserControl)Page.LoadControl("../controls/ucVote.ascx");
                plhdHome2.Controls.Add(controls);
            }
            else if (objDT.Rows[i]["type_id"].ToString() == "14")
            {
                UserControl controls = (UserControl)Page.LoadControl("../controls/ucMostview.ascx");
                Controls_ucMostview control = (Controls_ucMostview)controls;
                control.Module_id = objDT.Rows[i]["MODULE_ID"].ToString();
                control.Page_size = objDT.Rows[i]["PAGE_SIZE"].ToString();
                control.Module_title = objDT.Rows[i]["FULL_NAME"].ToString();
                plhdHome2.Controls.Add(controls);
            }
            else if (objDT.Rows[i]["type_id"].ToString() == "16")
            {
                UserControl controls = (UserControl)Page.LoadControl("../controls/ucStatistic.ascx");
                plhdHome2.Controls.Add(controls);
            }
        }
    }

    protected void LoadHome3Module()
    {
        DataTable objDT = null;
        if (Request["cid"] != null)
        {
            objDT = BO_Module.SelectLocation(4, Convert.ToInt32(Request["cid"]));
        }
        else
            objDT = BO_Module.SelectLocation(4);
        for (int i = 0; i < objDT.Rows.Count; i++)
        {
            if (objDT.Rows[i]["type_id"].ToString() == "6")
            {
                UserControl controls = (UserControl)Page.LoadControl("../controls/ucSmallAds.ascx");
                Controls_ucSmallAds control = (Controls_ucSmallAds)controls;
                control.Module_id = objDT.Rows[i]["MODULE_ID"].ToString();
                plhdHome3.Controls.Add(controls);
            }
        }
    }

}